package com.hogocloud.myframe.ui

import android.os.Bundle
import android.view.View
import com.google.android.flexbox.FlexboxLayoutManager
import com.hogocloud.corelibrary.base.BaseFragment
import com.hogocloud.myframe.R
import com.hogocloud.myframe.adapter.FlowLayoutLabelAdapter
import com.hogocloud.myframe.data.HomeViewModel
import kotlinx.android.synthetic.main.fragment_home.*
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.support.v4.startActivity


/**
 * class
 *
 * @author gjc
 * @version 1.0.0
 * @since 2019-08-01
 */
class HomeFragment : BaseFragment() {

    private lateinit var mHomeViewModel: HomeViewModel

    private val list = listOf("选择对应项", "拖动布局", "coordinator")

    override fun initLayout(): Int {
        return R.layout.fragment_home
    }

    override fun initView(view: View, savedInstanceState: Bundle?) {

        val adapter = FlowLayoutLabelAdapter(R.layout.item_flow_layout, list)
        rv_label.layoutManager = FlexboxLayoutManager(mContext)
        rv_label.adapter = adapter
        adapter.setOnItemClickListener { _, _, position ->
            when (position) {
                0 -> startActivity<SelectItemActivity>()
                1 -> {
                    startActivity<DragViewActivity>()
                }
                2 -> startActivity<CoordinatorActivity>()
            }
        }

        iv_record.onClick {
            pb_test.start()
        }

    }


}